/**
 * ch01.console.tinyCLI.js
 * 模拟一个简单的控制台界面
 */

var readline = require("readline");
var rl = readline.createInterface({
    input : process.stdin ,
    output : process.stdout
});
rl.setPrompt("nodeJS> ");
rl.prompt();
rl.on("line",function(line){
    switch(line.trim()){
        case 'name':
            console.log('king!');;
            break;
        case 'code':
            console.log('node.js!');
            break;
        case 'time':
            console.log('2015!');
            break;
        case 'close':
            console.log('Have a great day!');
            process.exit(0);
        default:
            console.log('Say what? I might have heard' +line.trim());
            break;


    }
    rl.prompt();
    
}).on('close',function(){
    console.log('Have a great day!');
    process.exit(0);
})